package cn.tedu.store.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.tedu.store.entity.Product;
import cn.tedu.store.service.IProductService;
import cn.tedu.store.util.JsonResult;

/**
 * 热销商品 控制器层
 * @author DELL
 *
 */
@RequestMapping("product")
@RestController
public class ProductController extends BaseController {
	
	@Autowired
	private IProductService service;
	
	@GetMapping("hot")
	public JsonResult<List<Product>> getHotList(){
		List<Product> data = service.getHotList();
		return new JsonResult<List<Product>>(SUCCESS,data);
	}
	
	@GetMapping("{pid}/details")
	public JsonResult<Product> getById( @PathVariable("pid")Integer pid){
		
		Product data = service.getById(pid);
		
		return new JsonResult<Product>(SUCCESS,data);
		
	}
	
}
